using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Web.SessionState;

namespace MCromwell.StaffIntranet.UI
{
    public class LoginManager
    {
        private const string SESSION_COOKIE_NAME = "AUTH_SESSION";
        
        public static void AddLogin(Guid SessionIdentifier)
        {
            HttpContext context = HttpContext.Current;
            HttpCookie sessionCookie = new HttpCookie(SESSION_COOKIE_NAME, SessionIdentifier.ToString());
            sessionCookie.HttpOnly = true;
            context.Response.AppendCookie(sessionCookie);
        }

        public static Guid RetrieveCurrentSessionIdentifer()
        {
            Guid sessionId = Guid.Empty;
            HttpContext context = HttpContext.Current;

            if (context.Request.Cookies[SESSION_COOKIE_NAME] != null)
                sessionId = new Guid(context.Request.Cookies[SESSION_COOKIE_NAME].Value);
            
            return sessionId;
        }

    }
}
